package com.dpj.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/searchNameServlet")
public class SearchNameServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String brandName = req.getParameter("brandName");
        List<String> list=new ArrayList<>();
        list.add("农夫三拳");
        list.add("娃哈哈");
        list.add("恰恰");
        list.add("安踏");
        list.add("李宁");
        list.add("李宁1");
        list.add("李宁2");
        list.add("李宁3");
        list.add("李宁4");
        list.add("鸿星尔克");
        list.add("1111");
        list.add("112");
        list.add("123");
        list.add("1123");
        list.add("1124");
        list.add("1125");

        List<String> result=new ArrayList<>();
        for (String s : list) {
            if(s.contains(brandName)){
                result.add(s);
            }
        }

        resp.getWriter().write(String.valueOf(result));
    }
}
